<?php echo $head ?>
<div class="right-content">
    <ul class="nav nav-tabs">
        <li class="active"><a href="#">修改商品</a></li>
    </ul>
    <style>
        .help-block {
            color: red !important;
        }
    </style>
    <form action="save" method="post" class="form-horizontal" role="form" enctype="multipart/form-data">
        <input type="hidden" name="id" value="">
        <div class="panel panel-info" style="display:block;">
            <div class="panel-body">
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">排序</label>
                    <div class="col-sm-9">
                        <input class="form-control" name="sort" id="sort" type="number" value="<?php echo $data['sort']?>">
                        <div class="help-block">正序排列 数字越小越靠前</div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">商品名称</label>
                    <div class="col-sm-9">
                        <input class="form-control" required="required" name="title" id="title" type="text" value="<?php echo $data['name']?>">
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">商品logo图</label>
                    <div class="col-sm-9">
                        <div class="input-group ">
                            <span class="input-group-btn">
                                <input type="file" class="btn btn-default" id="file0"  name="file0" multiple="multiple" value="选择图片">
			</span>
                        </div>
                        <img src="<?php echo $data['pic']?>" id="img0" width="120">
                    </div>
                </div>
                <script>
                    $("#file0").change(function(){
                        var objUrl = getObjectURL(this.files[0]) ;
                        console.log("objUrl = "+objUrl) ;
                        if (objUrl)
                        {
                            $("#img0").attr("src", objUrl);
                            $("#img0").removeClass("hide");
                        }
                    }) ;
                    //建立一個可存取到該file的url
                    function getObjectURL(file)
                    {
                        var url = null ;
                        if (window.createObjectURL!=undefined)
                        { // basic
                            url = window.createObjectURL(file) ;
                        }
                        else if (window.URL!=undefined)
                        {
                            // mozilla(firefox)
                            url = window.URL.createObjectURL(file) ;
                        }
                        else if (window.webkitURL!=undefined) {
                            // webkit or chrome
                            url = window.webkitURL.createObjectURL(file) ;
                        }
                        return url ;
                    }

                </script>


                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">闯关价格</label>
                    <div class="col-sm-9">
                        <div class="input-group">
                            <input class="form-control" name="price" id="price" type="text" value="<?php echo $data['play_money']?>">
                            <span class="input-group-addon">元</span>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">商品原价</label>
                    <div class="col-sm-9">
                        <div class="input-group">
                            <input class="form-control" name="costprice" id="costprice" type="text" value="<?php echo $data['original_price']?>">
                            <span class="input-group-addon">元</span>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">限制条件功能</label>
                    <div class="col-sm-9">
                        <div class="input-group">
                            <span class="input-group-addon">每当累计失败次数到</span>
                            <input class="form-control" name="succprice" type="number" min="0" value="<?php echo $data['limit']?>">
                            <span class="input-group-addon">次时，才放出一个该奖品</span>
                        </div>
                        <div class="help-block">如果次数不填或者为0，则不开启这个限制功能</div>
                        <div class="help-block">该功能原理：当前累计失败次数少于额定次数时，游戏第三关的最后三个箱子是必定失败的，难度不能低于较难，否则作弊看起来很明显</div>
                        <div class="help-block">达到该额定次数后，不是说一定能中奖品，而是程序不会作弊故意失败，中不中看用户玩的情况</div>
                        <div class="help-block">这个功能限制，不一定100%严格按照额定次数进行，也可能存在一定的误差</div>
                    </div>
                </div>
                <input type="hidden" name="id" value="<?php echo $data['id']?>">
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">状态</label>
                    <?php
                    $checked_1 = '';
                    $checked_2 = '';
                        if($data['status'] == 1){
                            $checked_2 = 'checked="checked"';
                        }else{
                            $checked_1 = 'checked="checked"';
                        }
                    ?>
                    <div class="col-sm-9">
                        <label><input type="radio" name="status" <?php echo $checked_1?> value="0"> 隐藏</label>
                        <label style="margin-left: 10px;"><input type="radio" <?php echo $checked_2?> name="status" value="1"> 显示</label>
                    </div>
                </div>
            </div>
        </div>
        <button type="submit" class="btn btn-primary" name="submit" id="summit_info" value="提交">保存</button>
        <input type="hidden" name="token" value="5f53e521">
    </form>
</div>